import {
  merge
} from 'lodash'
import AxiosRequest from './request'
import {
  baseURL
} from '@/components/storybook/settings/axios'

export function createAxios (opt) {
  return new AxiosRequest(
    merge({
      timeout: 1000 * 360,
      withCredentials: true,
      baseURL,
      requestOptions: {
        cache: {
          enable: false,
          timeout: 5 * 1000,
          failedReq: true
        },
        joinTime: true,
        isReturnNativeResponse: false,
        isTransformResponse: true,
        ignoreCancelToken: true,
        withToken: true,
        formatDate: true,
        joinParamsToUrl: false,
        retryRequest: {
          isOpenRetry: true,
          count: 5,
          waitTime: 100
        }
      }
    },
    opt || {}
    )
  )
}
